package com.bbu.javaexam.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bbu.javaexam.domain.RespData;
import com.bbu.javaexam.service.impl.AnswerServiceImpl;
import com.bbu.javaexam.domain.vo.AnswerVO;
import com.bbu.javaexam.util.RespDataHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Alex
 * @version 1.0.0
 * @ClassName AnswerController.java
 * @Description TODO
 */
@RestController
public class AnswerController {
    @Autowired
    private AnswerServiceImpl answerService;

    @GetMapping("/answers/{page}/{size}")
    public RespData findAllQuestion(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
        Page<AnswerVO> answerVOPage = new Page<>(page, size);
        IPage<AnswerVO> answerVOIPage = answerService.findAll(answerVOPage);
        return RespDataHandler.buildRespData(200, "查询所有题库", answerVOIPage);
    }
}
